# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=mujs
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.3
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="http://mujs.com/"
license=('spdx:AGPL-3.0')
pkgdesc='A lightweight Javascript interpreter designed for embedding in other software (mingw-w64)'
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-readline")
source=("https://mujs.com/downloads/${_realname}-${pkgver}.tar.gz"
        "001-makefile-fix.patch")
sha256sums=('e2c5ee5416dfda2230c7a0cb7895df9a9b2d5b2065bb18e7e64dec2a796abe1b'
            '7f53d258b84155c1266d339089a8a5bb30c9da60a12d87b4c4b7d53a0f487147')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 < ../001-makefile-fix.patch
}

build() {
  cd ${_realname}-${pkgver}
  make prefix=${MINGW_PREFIX} release
}

package() {
  cd ${_realname}-${pkgver}
  make DESTDIR=${pkgdir} prefix=${MINGW_PREFIX} install

  install -Dm644 COPYING $pkgdir${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
  install -Dm644 README $pkgdir${MINGW_PREFIX}/share/doc/${_realname}/README
  cd docs/; for i in *; do
    install -Dm644 $i ${pkgdir}${MINGW_PREFIX}/share/doc/${_realname}/$i
  done
}
